Copy module between folders

Hi,

Is anyone one aware of an undocumented feature to enable the copy of a module from one folder to another? I have no problem copying an existing module within the same folder and renaming, but need to copy a template module to another folder.

I've toyed with copying, renaming, moving and renaming again but this is extremely clumsy.

Mark
mwilliamson - Wed Jun 16 12:15:21 EDT 2010

Re: Copy module between folders
llandale - Wed Jun 16 21:36:57 EDT 2010

You can copy it, change to the new folder, then paste it. Use the right-mouse click menu. You can also paste-special it as a way to 'clone' it.

When you copy, you don't get Baselines and you don't get embedded Module Triggers. If you want an exact copy you should archive and restore it.

  • Louie

Re: Copy module between folders
mwilliamson - Thu Jun 17 02:58:36 EDT 2010

llandale - Wed Jun 16 21:36:57 EDT 2010
You can copy it, change to the new folder, then paste it. Use the right-mouse click menu. You can also paste-special it as a way to 'clone' it.

When you copy, you don't get Baselines and you don't get embedded Module Triggers. If you want an exact copy you should archive and restore it.

  • Louie

Hi Louie,

Thanks for the reply. I probably didn't explain myself very well. I know how to copy and paste / clone within the DOORS client. I need to carry out the same copy functionality using DXL. The scenario is that the user can create a new 'implementation' through a dialog box, providing the details to create a new 'implementation' folder at the appropriate place in the database. Once this is created, reference modules are copied to the new folder for further specification.

I was just having an issue copying the reference modules in the dxl. I have since discovered clipCopy(Item) and clipPaste(Folder) and think that they may do the job once I've figured out how to specify the folder handle.

Thanks

Mark

Re: Copy module between folders
llandale - Thu Jun 17 11:59:30 EDT 2010

mwilliamson - Thu Jun 17 02:58:36 EDT 2010
Hi Louie,

Thanks for the reply. I probably didn't explain myself very well. I know how to copy and paste / clone within the DOORS client. I need to carry out the same copy functionality using DXL. The scenario is that the user can create a new 'implementation' through a dialog box, providing the details to create a new 'implementation' folder at the appropriate place in the database. Once this is created, reference modules are copied to the new folder for further specification.

I was just having an issue copying the reference modules in the dxl. I have since discovered clipCopy(Item) and clipPaste(Folder) and think that they may do the job once I've figured out how to specify the folder handle.

Thanks

Mark

I don't seem to have an example of it, but

ModName_ mnFrom = module(NameFromFull)
string  Description = description(mnFrom)
bool      OK      = copy(ModName_,string NameToBase, string Description)
ModName  mnTo   = module(full name of NameToBase)
string  ErrMess = move(ModName_,Folder)
string  ErrMess = rename(ModName_,string NameToBase,string Description)


These commands in that order should do it. Copy module "/MyProj/MyFolder/A" to "A1". Move module "/MyProj/MyFolder/A1" to destination Folder "/MyProj/MyOtherFolder". Rename "/MyProj/MyOtherFolder/A1" back to "A", preserving the Descrition of A1.

 

 

  • Louie

 

 

Re: Copy module between folders
mwilliamson - Thu Jun 17 12:17:30 EDT 2010

llandale - Thu Jun 17 11:59:30 EDT 2010

I don't seem to have an example of it, but

ModName_ mnFrom = module(NameFromFull)
string  Description = description(mnFrom)
bool      OK      = copy(ModName_,string NameToBase, string Description)
ModName  mnTo   = module(full name of NameToBase)
string  ErrMess = move(ModName_,Folder)
string  ErrMess = rename(ModName_,string NameToBase,string Description)


These commands in that order should do it. Copy module "/MyProj/MyFolder/A" to "A1". Move module "/MyProj/MyFolder/A1" to destination Folder "/MyProj/MyOtherFolder". Rename "/MyProj/MyOtherFolder/A1" back to "A", preserving the Descrition of A1.

 

 

  • Louie

 

 

Hi Louie, I fixed it with the following code:

void copyTemplates(Folder f)
{
    string new = get(newImp)//get new folder name from dialog
        string x = "Parent folder location"
        string y = new
        string z = x y //concat parent and new folder for full path
        Item itemRef
        int i = 0
        for itemRef in (current Folder) do
        {     
                i++          
                clipCopy(itemRef)//copy reference modules. 
                clipPaste( folder z ) //Paste in designated implementation folder
                clipClear()           // Clear clipboard
        }
}

 


Many thanks for your replies.

Mark

 

Re: Copy module between folders
llandale - Thu Jun 17 12:56:47 EDT 2010

mwilliamson - Thu Jun 17 12:17:30 EDT 2010

Hi Louie, I fixed it with the following code:

void copyTemplates(Folder f)
{
    string new = get(newImp)//get new folder name from dialog
        string x = "Parent folder location"
        string y = new
        string z = x y //concat parent and new folder for full path
        Item itemRef
        int i = 0
        for itemRef in (current Folder) do
        {     
                i++          
                clipCopy(itemRef)//copy reference modules. 
                clipPaste( folder z ) //Paste in designated implementation folder
                clipClear()           // Clear clipboard
        }
}

 


Many thanks for your replies.

Mark

 

Let us know exactly what indeed gets copied using the Clipboard. Objects and Attributes and module/object attr values of course, but what about Baselines and Triggers and Views and outgoing links and all access rights?

Re: Copy module between folders
mwilliamson - Fri Jun 18 04:49:04 EDT 2010

llandale - Thu Jun 17 12:56:47 EDT 2010
Let us know exactly what indeed gets copied using the Clipboard. Objects and Attributes and module/object attr values of course, but what about Baselines and Triggers and Views and outgoing links and all access rights?

Louie,

Views and access rights get copied but baselines don't. Not sure about triggers as I tend to avoid them wherever possible!

Mark

Re: Copy module between folders
ThomasD. - Thu Mar 20 14:51:41 EDT 2014

llandale - Thu Jun 17 11:59:30 EDT 2010

I don't seem to have an example of it, but

ModName_ mnFrom = module(NameFromFull)
string  Description = description(mnFrom)
bool      OK      = copy(ModName_,string NameToBase, string Description)
ModName  mnTo   = module(full name of NameToBase)
string  ErrMess = move(ModName_,Folder)
string  ErrMess = rename(ModName_,string NameToBase,string Description)


These commands in that order should do it. Copy module "/MyProj/MyFolder/A" to "A1". Move module "/MyProj/MyFolder/A1" to destination Folder "/MyProj/MyOtherFolder". Rename "/MyProj/MyOtherFolder/A1" back to "A", preserving the Descrition of A1.

 

 

  • Louie

 

 

Hi Louie,

What if the user doesn't have the right to create a module in the current Folder but only in the target Folder ?

The only solution I have found so far (except Mark's solution with the clipboard) is to use a script from the Kitchen ("duplicate.dxl", which also uses other functions from other Kitchen files) and adapt it a little for my needs.

FYI, that script creates an empty module at the target location, then copies every object from the old module depending on its absolute number, then moves every object using the "Object Number" information from the old module, and finally sets the correct level for every object, and I'm skipping the details about tables and deleted objects! As it appears it doesn't even copy module attributes nor views (these aspects can be easily fixed using other Kitchen functions, though).

That seems pretty complicated compared to the "copy" function, therefore I just can't believe that there is no easier way than that... I guess the clipboard will be my friend for that matter if you don't know of any better solution...

Thanks,

Thomas

 

Re: Copy module between folders
KBSri - Thu Apr 03 06:49:59 EDT 2014

mwilliamson - Thu Jun 17 12:17:30 EDT 2010

Hi Louie, I fixed it with the following code:

void copyTemplates(Folder f)
{
    string new = get(newImp)//get new folder name from dialog
        string x = "Parent folder location"
        string y = new
        string z = x y //concat parent and new folder for full path
        Item itemRef
        int i = 0
        for itemRef in (current Folder) do
        {     
                i++          
                clipCopy(itemRef)//copy reference modules. 
                clipPaste( folder z ) //Paste in designated implementation folder
                clipClear()           // Clear clipboard
        }
}

 


Many thanks for your replies.

Mark

 

Hello Mark,

I tried the following code. But could not copy the module between the folders.

Thanks & Regards.

 

Re: Copy module between folders
alexvandv - Tue Apr 25 14:27:11 EDT 2017

Dear all,

 

I'm new to dxl scripting, and I've been trying to copy a module from one project folder, to a different project folder. I used the examples above, but so far I haven't obtained any success.

Here's how my script looks like:

// originalModule is a the path of the original file to be copied.
// targetPath is the path of the target project location of where the module should 
// be pasted

ModName_ originalMMP = module(originalModule)
string originalMMPdesc = description(originalMMP)
clipCopy(originalMMP) // Not sure If I should be using paths here, but got the same error.
clipPaste(targetPath)
clipClear()

// copiedModule is the path of the pasted module
// This is an attempt of renaming the pasted file.
ModName_ copiedMMP = module(copiedModule)
ErrMess = rename(copiedMMP,newModuleName, originalMMPdesc)

Any ideas of what could be possibly going wrong? I'm not entirely sure of how the clipCopy and clipPaste work. I've been getting "incorrect arguments for functions" for both of them.

 

Thank you for your time,

Alex

Re: Copy module between folders
EHcnck - Tue Apr 25 20:15:02 EDT 2017

mwilliamson - Thu Jun 17 12:17:30 EDT 2010

Hi Louie, I fixed it with the following code:

void copyTemplates(Folder f)
{
    string new = get(newImp)//get new folder name from dialog
        string x = "Parent folder location"
        string y = new
        string z = x y //concat parent and new folder for full path
        Item itemRef
        int i = 0
        for itemRef in (current Folder) do
        {     
                i++          
                clipCopy(itemRef)//copy reference modules. 
                clipPaste( folder z ) //Paste in designated implementation folder
                clipClear()           // Clear clipboard
        }
}

 


Many thanks for your replies.

Mark

 

what about archive/restore?